package classes.controlers {
	import classes.managers.Game_Manager;
	import classes.sounds.SoundCollection;
	import flash.display.MovieClip;
	
	
	/**
	 * ...
	 * @author Kihoonee
	 */
	public class Rope_Rabbits_Controler extends A_Controler {
		private var left:MovieClip; //왼쪽토끼
		private var right:MovieClip; //오른쪽토끼
		
		private var randomSpeedCnt:int = 0;
		
		public function Rope_Rabbits_Controler( _gm:Game_Manager, _mc:MovieClip ) {
			super( _gm, _mc );
			
			left = mc.left_mc;
			right = mc.right_mc;
			
			init();
		}
		
		public function init():void {
			randomSpeedCnt = 0;
			
			left.gotoAndStop( "속도5" );
			right.gotoAndStop( "속도5" );
		}
		
		public function twist( _level:int ):void {
			switch ( _level ) {
				case 1: left.gotoAndStop("속도5"); right.gotoAndStop("속도5");
				break;
				case 2: left.gotoAndStop("속도5"); right.gotoAndStop("속도5");
				break;
				case 3: left.gotoAndStop("속도5"); right.gotoAndStop("속도5");
				break;
				case 4: left.gotoAndStop("속도5"); right.gotoAndStop("속도5");
				break;
				case 5: left.gotoAndStop("속도5"); right.gotoAndStop("속도5");
				break;
				case 6: left.gotoAndStop("속도5"); right.gotoAndStop("속도5");
				break;
				case 7: left.gotoAndStop("속도1"); right.gotoAndStop("속도1");
						ropeRandomSpeed();
				break;
				default:
			}
		}
		
		private function ropeRandomSpeed():void {
			if ( randomSpeedCnt < 3 ) {
				left.gotoAndStop("속도1"); right.gotoAndStop("속도1");
			}else if ( randomSpeedCnt >= 3 && randomSpeedCnt < 6 ) {
				left.gotoAndStop("속도2"); right.gotoAndStop("속도2");
			}else if ( randomSpeedCnt >= 6 && randomSpeedCnt < 9 ) {
				left.gotoAndStop("속도3"); right.gotoAndStop("속도3");
			}else if ( randomSpeedCnt >= 9 && randomSpeedCnt < 14 ) {
				left.gotoAndStop("속도4"); right.gotoAndStop("속도4");
			}else if ( randomSpeedCnt >= 14 && randomSpeedCnt < 18 ) {
				left.gotoAndStop("속도5"); right.gotoAndStop("속도5");
			}else if ( randomSpeedCnt >= 18 && randomSpeedCnt < 23 ) {
				left.gotoAndStop("속도6"); right.gotoAndStop("속도6");
			}else if ( randomSpeedCnt >= 23 && randomSpeedCnt < 28 ) {
				left.gotoAndStop("속도7"); right.gotoAndStop("속도7");
			}else if ( randomSpeedCnt >= 28 && randomSpeedCnt < 32  ) {
				left.gotoAndStop("속도8"); right.gotoAndStop("속도8");
			}else if ( randomSpeedCnt >= 32 && randomSpeedCnt < 36  ) {
				left.gotoAndStop("속도9"); right.gotoAndStop("속도9");
			}else if ( randomSpeedCnt >= 36 ) {
				left.gotoAndStop("속도10"); right.gotoAndStop("속도10");
				SoundCollection.superRabbitSound();
			}
			randomSpeedCnt++;
		}
		
		public function pause():void {
			left.gotoAndStop( "pause" );
			right.gotoAndStop( "pause" );
		}
	}

}